# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-psq
_pkgname=psq
pkgver=0.2.0
pkgrel=0
pkgdesc="Functional Priority Search Queues"
url="https://github.com/pqwy/psq"
arch="all !riscv64"  # limited by ocaml aport
license="ISC"
depends="ocaml-runtime ocaml-seq"
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-seq-dev"
makedepends="dune ocaml"
checkdepends="ocaml-alcotest-dev ocaml-qcheck-alcotest-dev ocaml-qcheck-core-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/pqwy/psq/releases/download/v$pkgver/psq-v$pkgver.tbz"
builddir="$srcdir/$_pkgname-v$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
0c570c5fc2bb2348b1ec03507abb4f152673a5d8f92c388c4cd5b7fc43a6e8f514007dbf4fb613503c4e8d5c8d3210b24ac37c546c79d94ebdf6b482e5cde024  ocaml-psq-0.2.0.tar.bz2
"
